//
//  OneTableViewCell.swift
//  SwiftDemo
//
//  Created by hs on 2017/7/11.
//  Copyright © 2017年 jiachen. All rights reserved.
//

import UIKit

class OneTableViewCell: UITableViewCell {
    public var stumodel:Student!
    
    private let userNameLab = UILabel.init()
    private let headerImage = UIImageView.init()
    private let sixLab = UILabel.init()
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.drawUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        fatalError("init(coder:) has not been implemented")
    }
    
    func drawUI() {
        
        headerImage.frame = CGRect.init(x: 10, y:10, width:100 - 20, height: 100 - 20)
        headerImage.backgroundColor = UIColor.red
        self.contentView.addSubview(headerImage)
        
        userNameLab.frame = CGRect.init(x:headerImage.frame.origin.x + headerImage.frame.width + 10, y:10, width:100, height:20)
        userNameLab.textAlignment = NSTextAlignment.left
        userNameLab.textColor = UIColor.black
        self.contentView.addSubview(userNameLab)
        
        sixLab.frame = CGRect.init(x: headerImage.frame.origin.x + headerImage.frame.width + 10, y:headerImage.frame.origin.y + headerImage.frame.size.width - 20 , width:100 , height:20)
        sixLab.textAlignment = NSTextAlignment.left
        sixLab.textColor = UIColor.black
        self.contentView.addSubview(sixLab)
        
    }
    
    func setStudent(_ stu:Student){
        self.stumodel = stu
        self.userNameLab.text = stu.name
        self.sixLab.text = stu.coordinates.0
        self.headerImage.image = UIImage.init(named: stu.headImageName)
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
